#ifndef CCOMHEAD_H
#define CCOMHEAD_H

#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

#define Car 1
#define Pes 2
#define Bike 3
#define RoadBlock 4

#define UDP_SEND_SRC        'a'
#define UDP_SEND_DET        'b'
#define UDP_SEND_DETLIST    'c'
#define UDP_SEND_LEFTLIST   'd'
#define UDP_SEND_RIGHTLIST  'e'

#define SEND_SRC        0x1
#define SEND_DET        0x2
#define SEND_DETLIST    0x4
#define SEND_SEG        0x8

#define MAX_DETLIST_SIZE 1024*10
#define MAX_SEGLIST_SIZE 1024*20

#define HEAD_MARK       0xabcd0001

#define UDP_WARN_FCW_NONE 0x1
#define UDP_WARN_FCW_WARN_1 0x2
#define UDP_WARN_FCW_WARN_2 0x4
#define UDP_WARN_LDW_NONE 0x8
#define UDP_WARN_LDW_LEFT_WARN_1 0x10
#define UDP_WARN_LDW_LEFT_WARN_2 0x20
#define UDP_WARN_LDW_RIGHT_WARN_1 0x40
#define UDP_WARN_LDW_RIGHT_WARN_2 0x80


#define PIC_MAT_TYPE        CV_8UC3

enum class_enum {NONE_OBJECT, CAR, PES, BICYCLE, ROADBLOCK};

enum FocusModeValue
{
    eFocusShort,
    eFocusMiddle,
    eFocusLong
};

struct DetecResultC{
    int id;
    int label;
    float score;
    float xmin ;
    float ymin ;
    float xmax ;
    float ymax ;
    float real_x;
    float real_y;
    float v_x;
    float v_y;
};

struct LaneData
{
    u_char id;
    //俯视二次曲线
    float polynomial[4];
    float start_point;
    float end_point;
    float distance;
    uint slope;
    float one_fit[2];
    // 补线之后的点按照2次拟合
    float front_fit[4];
    int front_start_point;
    int front_end_point;
    float front_one_fit[2];
    // score = prob_mean
    float score;
    //是否为直道
    bool is_straight;
};

struct SUdpDataHead
{
    int mHeadMark;
    int mSendMask;
    int mRcvMask;
    int mIndex;
};

struct SUdpData
{
    Mat src;
    SUdpDataHead udp_head;
};

typedef struct
{
    int mMsgParamLen;
    int mDetListLen;
    char mMsgParam[0]; // 表示不定长
} SUdpDetRestlMsg,*SUdpDetRestlMsgP;
/*
    使用不定长的结构体发送数据的关键在于:
    不能在结构体中使用指针变量, 改用mMsgParam[0]这种写法
    因为mMsgParam[0]不定长, 所以结构体变量要分配到堆中, 即用malloc或new来分配空间
    接收的话, 就申请一个大一点的buffer, 一次接收完发送端发过来的不定长数据即可
    因为UDP的特点: UDP发一包就是一包, 要么收到, 要么收不到一个完整的包
*/

typedef struct
{
    int mMsgParamLen;
    int mDetListN;
    int mDetListLen[10];
    char mMsgParam[0]; // 表示不定长
} SUdpSegResltMsg,*SUdpSegResltMsgP;

// 长焦图像转换到短焦中心点及左上角点
struct TransPoint
{
    int centerX;
    int centerY;
    int startX;
    int startY;
    TransPoint(int _centerX, int _centerY)
    {
        centerX = _centerX;
        centerY = _centerY;
    }
    TransPoint(int _centerX, int _centerY, int _startX, int _startY)
    {
        centerX = _centerX;
        centerY = _centerY;
        startX = _startX;
        startY = _startY;
    }
};

#endif
